package com.bit.cfdi.web.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.bit.cfdi.web.dao.DesgloseComprobanteDAO;
import com.bit.cfdi.web.domain.DesgloseComprobante;

@Repository
public class DesgloseComprobanteDAOImpl extends HibernateDaoSupport 
	implements DesgloseComprobanteDAO {

	@Autowired
	public void init(final SessionFactory sessionFactory) {
		setSessionFactory(sessionFactory);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	@Transactional 
	public List<DesgloseComprobante> getAll() {
		List<DesgloseComprobante> desgloses = getHibernateTemplate().find(
				"FROM DesgloseComprobante as dc ");
		return desgloses;
	}

	@Override
	@Transactional 
	public void save(DesgloseComprobante desgloseComprobante) {
		getHibernateTemplate().saveOrUpdate(desgloseComprobante);
	}

}
